﻿using UnityEngine;
using UnityEditor;
using System.Collections;
//////////////////////////////////////////////////////
///设置选中的GameObject的静态属性.
//////////////////////////////////////////////////////
public class SetAllStatic : MonoBehaviour {
	static string title = "注意";
	static string message = "将物体设置为:";
	static string ok = "静态";
	static string cancel = "非静态";
	static string alt = "取消";
	[MenuItem("Level4/Other/SetAllStatic")]
	static void Init(){
		GameObject[] objs = Selection.gameObjects;
		if(objs.Length > 0){
			int opt = EditorUtility.DisplayDialogComplex(title,message,ok,cancel,alt);
			bool isStatic = false;
			bool isCancel = false;
			switch(opt){
				case 0:
					isStatic = true;
					break;
				case 2:
					isCancel = true;
					break;
			}
			// Undo.RegisterSceneUndo("Set All GameObject to Static.");
			Undo.RecordObjects(objs,"Set All GameObject to Static.");
			if(!isCancel){
				foreach(GameObject go in objs){
					if(go != null){
						go.isStatic = isStatic;
					}
				}
			}
		}
	}
	
	
}
